
import http from '@/api/axios';
// import http from './http';
import type * as VideoType from '../type';
import type { AxiosResponse } from 'axios';
/**
 * 接口：追踪按钮调用api
 * 入参：
 出参：
 */
export function algorithmTrace( model: any ) {
	return http.post("/anno/ultrasound/video/trace", model);
}


/**
 * 新接口：视频切割后的获取接口，包含原始的帧信息
 * 入参：{"seriesUid":""}
	出参：{"code":0,"data":{"frames":"http://sxss.zip", "seconds":20, "framesOfSecond": 15}}
 */
export function videoFrameInfo( model: VideoType.VideoFrameInfoModel ) {
	return http.post<VideoType.VideoInfo>("/anno/ultrasound/video/frame/info", model);
}

/**
 * 
 * 在标注结果读取接口中新增病灶组信息
	在imageAnnotationResultList同级新增字段："iarGroupList": [{"id":1,"type":"","uuid":"","info":""}]
 */
export function readSeriesResult( model:any ) {
	return http.post("/anno/result/read", model);
}

/**
 * 
 * 创建病灶组(帧段)
	入参：{"taskId":1,"userId":1,"type":"ultrasound","info":"{"startFrame":5,"endFrame":10}"}
	返回：{"code":0, "data":{"id":1,"uuid":""}}
 */
export function reateIarGroup( model:VideoType.ReateIarGroupModel ) {
	return http.post("/anno/lesion/result/group", model);
}

/**
 * 
 * 删除病灶组（组内没有病灶才可以删除）
	入参：{"id":1}
 */
export function deleteIarGroup( model:VideoType.IdModel ) {
	return http.delete("/anno/lesion/result/group", {params: model});
}

//删除病灶
export function deleteAnnoResult( model:VideoType.IdModel ) {
	return http.post("/aaa/v1/anno/image_result/delete", model);
}

/**
 * 
 * 新接口：更新病灶组信息
	入参：{"id":1,"info":"{"startFrame":5,"endFrame":10}"}
 */
export function updateIarGroup( model:any ) {
	return http.put("/anno/lesion/result/group", model);
}

/**
 *  创建病灶
 *6、老接口：创建病灶需要传入组uuid
入参：{"seriesAnnotationResultId":1,"imageAnnotationId":1,"imageAnnotationToolId":1,"result":"","resultGroupUuid":""}
出参：{"code":0,"data":{"id":1}}
 */
export function annoCreate( model:VideoType.AnnoCreateModel ) {
	return http.post<VideoType.IdModel>("/anno/lesion/result/point", model);
}

//更新病灶
export function annoUpdate( model:VideoType.AnnoUpdateModel ) {
	return http.put<VideoType.IdModel>("/anno/lesion/result/point", model);
}

//小征象
export function imageResultEdit( model:VideoType.imageResultEditModel ) {
	return http.post<VideoType.IdModel>("/aaa/v1/anno/image_result/item/edit", model);
}

//大征象
export function seriesResultEdit( model:VideoType.seriesResultEditModel ) {
	return http.post<VideoType.IdModel>("/aaa/v1/anno/series_result/item/edit", model);
}


//标注类型
export function lesionConfig(param: any) {
	return http.post<any[]>("/config/lesion/search", param);
}
//配置字典
export function commonConfig(param: any) {
	return http.post<any[]>("/config/common/list", param);
}

export function childQuery() {
	return http.post<any[]>("/aaa/v1/dict/child/query", {value:null});
}

interface UserSeriesGetModel {
	taskId: string | number,
	userId: string | number
}
//开始任务时获取下一个标注组
export function userSeriesGet( model: any ) {
	return http.post("/anno/result/series/get", model);
}
//标注结果读取
export function getSeriesResult( model: any ){
	return http.post("/anno/result/read", model)
}
//
export function taskRead( model:any ) {
	return http.post<any>("/anno/setting/read", model);
}

export function projectRead( taskId:any ) {
	return http.get<any>(`/anno/task/${taskId}`);
}

export function login( model:any ) {
	return http.post("/aaa/v1/user/login", model);
}

// 提交
export function submit(sarIdList: string) {
	return http.post<VideoType.CommonRes>("/aaa/v1/anno/series_result/submit", {sarIdList});
}

// 标记废片
export function saveDiscard(params: VideoType.DiscardParams) {
	return http.post<VideoType.CommonRes>("/aaa/v1/anno/series_result/discard", params);
}

export function fetchDiscardList(id: number) {
	return http.post("/aaa/v1/project/discard/list", {id});
}

// 标注为阴阳性
export function updateYay(params: VideoType.YayParams) {
	return http.post<VideoType.CommonRes>("/aaa/v1/anno/series_result/yayAttributes", params);
}
interface CurrentItem {
	annoLastUpdateTime: null | Date;
	annoUpdateStatus: null | number;
	auditStatus: null | number;
	endTime: number | Date;
	id: number;
	name: string;
	seriesAnnotationResultId: number;
	seriesAvailableNum: number;
	status: number;
}
// 获取剩余可分配的序列
export function getSurPlusSeries(userId: number) {
	return http.post<CurrentItem>("/aaa//v1/user/task/currentList", {userId});
}

// 获取已标注的序列
export function getSeiesList(params: any) {
	return http.post<VideoType.SeriesList>("/anno/user/task/series/search", params);
}